use std::collections::HashMap;

use lavender::api::http_request;
use serde::{Serialize, Deserialize};

#[derive(Debug,Serialize, Deserialize)]
#[serde(untagged)]
pub enum EastMoneyFieldValue {
    Int(i32),
    Float(f32),
    Str(String),
}
#[derive(Debug,Serialize, Deserialize)]
pub struct EastMoneyBaseInfo{
    pub rc:i32,
    pub rt:i32,
    pub data:HashMap<String,EastMoneyFieldValue>
}

#[tokio::test]
async fn test_http_get_json(){    
    let url  ="https://push2.eastmoney.com/api/qt/stock/get?invt=2&fltt=1&fields=f58,f107,f57,f43,f59,f169,f301,f60,f170,f152,f46,f44,f45,f47,f48,f19,f17,f531,f15,f13,f11,f20,f18,f16,f14,f12,f39,f37,f35,f33,f31,f40,f38,f36,f34,f32,f211,f212,f213,f214,f215,f210,f209,f208,f207,f206,f161,f49,f171,f50,f86,f84,f85,f168,f108,f116,f167,f164,f162,f92,f71,f117,f292,f51,f52,f191,f192,f177,f740&secid=0.838402&ut=fa5fd1943c7b386f172d6893dbfba10b&wbp2u=|0|0|0|web&_=1684217536637";

    let resp = http_request::http_get_json::<EastMoneyBaseInfo>(url,vec![("Content-Type","application/json"),("Accept","application/json")],3).await;
    println!("resp: {:?}",resp);
}